package com.xmy.solution.service.impl;

import java.util.List;
import com.xmy.common.utils.DateUtils;
import com.xmy.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xmy.solution.mapper.AnnouncementsMapper;
import com.xmy.solution.domain.Announcements;
import com.xmy.solution.service.IAnnouncementsService;

/**
 * 公告管理Service业务层处理
 * 
 * @author 夏明毅
 * @date 2024-12-30
 */
@Service
public class AnnouncementsServiceImpl implements IAnnouncementsService 
{
    @Autowired
    private AnnouncementsMapper announcementsMapper;

    /**
     * 查询公告管理
     * 
     * @param id 公告管理主键
     * @return 公告管理
     */
    @Override
    public Announcements selectAnnouncementsById(Long id)
    {
        return announcementsMapper.selectAnnouncementsById(id);
    }

    /**
     * 查询公告管理列表
     * 
     * @param announcements 公告管理
     * @return 公告管理
     */
    @Override
    public List<Announcements> selectAnnouncementsList(Announcements announcements)
    {
        return announcementsMapper.selectAnnouncementsList(announcements);
    }

    /**
     * 新增公告管理
     * 
     * @param announcements 公告管理
     * @return 结果
     */
    @Override
    public int insertAnnouncements(Announcements announcements)
    {
        announcements.setCreateTime(DateUtils.getNowDate());
        announcements.setCreateBy(SecurityUtils.getUsername());
        announcements.setStatus(0l);
        return announcementsMapper.insertAnnouncements(announcements);
    }

    /**
     * 修改公告管理
     * 
     * @param announcements 公告管理
     * @return 结果
     */
    @Override
    public int updateAnnouncements(Announcements announcements)
    {
        announcements.setUpdateTime(DateUtils.getNowDate());
        announcements.setUpdateBy(SecurityUtils.getUsername());
        return announcementsMapper.updateAnnouncements(announcements);
    }

    /**
     * 批量删除公告管理
     * 
     * @param ids 需要删除的公告管理主键
     * @return 结果
     */
    @Override
    public int deleteAnnouncementsByIds(Long[] ids)
    {
        return announcementsMapper.deleteAnnouncementsByIds(ids);
    }

    /**
     * 删除公告管理信息
     * 
     * @param id 公告管理主键
     * @return 结果
     */
    @Override
    public int deleteAnnouncementsById(Long id)
    {
        return announcementsMapper.deleteAnnouncementsById(id);
    }

    @Override
    public List<Announcements> selectAppAnnouncementsList(Announcements announcements) {
        return announcementsMapper.selectAppAnnouncementsList(announcements);
    }
}
